const Mock = require('mockjs')

const Random = Mock.Random

let Result = {
    code: 200,
    msg: '操作成功',
    data: null
}
//验证码
Mock.mock('/captcha', 'get', () => {
    Result.data = {
        token: Random.string(32),
        captchaImg: Random.dataImage("120x40", 'p7n5w')
    }
    return Result;
})
//登录
Mock.mock('/login', 'post', () => {
    //无法在header中传入数据jwt

    // Result.code = 400
    // Result.msg = "验证码错误"
    return Result;
})
//用户信息
Mock.mock('/sys/userInfo', 'get', () => {
    Result.data = {
        id: "1",
        username: "test",
        avatar: "https://tse1-mm.cn.bing.net/th/id/R-C.535d83285a3101b437ea594d0bed88cf?rik=L%2ftEGhkbS1ik5A&riu=http%3a%2f%2fimg.ewebweb.com%2fuploads%2f20191010%2f15%2f1570692559-BGIZFbCdfK.png&ehk=tkDFeqofQYqxTY%2bTgjxx3PP5QOO6k7e%2buIZsTAmJIHc%3d&risl=&pid=ImgRaw&r=0"
    }
    return Result;
})
//退出登录
Mock.mock('/logout', 'post', () => {

    return Result;
})
//菜单管理
Mock.mock('/sys/menu/nav', 'get', () => {
    let nav = [
        {
            title: '系统管理',
            name: 'SysMange',
            icon: 'el-icon-s-operation',
            component: '',
            path: '',
            children: [
                {
                    title: '用户管理',
                    name: 'SysUser',
                    icon: 'el-icon-s-custom',
                    path: '/sys/users',
                    component: 'sys/User',
                    children: []
                },
                {
                    title: '角色管理',
                    name: 'SysRole',
                    icon: 'el-icon-rank',
                    path: '/sys/roles',
                    component: 'sys/Role',
                    children: []
                },
                {
                    title: '菜单管理',
                    name: 'SysMenu',
                    icon: 'el-icon-menu',
                    path: '/sys/menus',
                    component: 'sys/Menu',
                    children: []
                }
            ]
        },
        {
            title: '系统工具',
            name: 'SysTools',
            icon: 'el-icon-s-tools',
            path: '',
            children: [
                {
                    title: '数字字典',
                    name: 'SysMange',
                    icon: 'el-icon-s-order',
                    path: '',
                    children: []
                }
            ]
        }
    ]
    let authoritys = []

    Result.data = {
        nav: nav,
        authoritys: authoritys
    }

    return Result;
})
Mock.mock('/sys/menu/list', 'get', () => {
    let menus = [
        {
            "id": 1,
            "created": '2022-05-12T18:58:18',
            "updated": '2022-05-12T18:58:18',
            "statu": 1,
            "parentId": 1,
            "name": '系统管理',
            "path": '',
            "perms": 'sys:manage',
            "component": '',
            "type": 0,
            "icon": 'el-icon-s-operation',
            "orderNum": 1,
            "children": [
                {
                    "id": 2,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "parentId": 1,
                    "name": '用户管理',
                    "path": '/sys/users',
                    "perms": 'sys:user:list',
                    "component": 'sys/User',
                    "type": 1,
                    "icon": 'el-icon-s-custom',
                    "orderNum": 1,
                    "children": [
                        {
                            "id": 4,
                            "created": '2022-05-12T18:58:18',
                            "updated": '2022-05-12T18:58:18',
                            "statu": 1,
                            "parentId": 1,
                            "name": '添加用户',
                            "path": '/sys/users',
                            "perms": 'sys:user:list',
                            "component": 'sys/User',
                            "type": 2,
                            "icon": 'el-icon-s-custom',
                            "orderNum": 1,
                            "children": []
                        },{
                            "id": 7,
                            "created": '2022-05-12T18:58:18',
                            "updated": '2022-05-12T18:58:18',
                            "statu": 1,
                            "parentId": 1,
                            "name": '编辑用户',
                            "path": '/sys/users',
                            "perms": 'sys:user:list',
                            "component": 'sys/User',
                            "type": 2,
                            "icon": 'el-icon-s-custom',
                            "orderNum": 1,
                            "children": []
                        },{
                            "id": 8,
                            "created": '2022-05-12T18:58:18',
                            "updated": '2022-05-12T18:58:18',
                            "statu": 1,
                            "parentId": 1,
                            "name": '删除用户',
                            "path": '/sys/users',
                            "perms": 'sys:user:list',
                            "component": 'sys/User',
                            "type": 2,
                            "icon": 'el-icon-s-custom',
                            "orderNum": 1,
                            "children": []
                        },{
                            "id": 9,
                            "created": '2022-05-12T18:58:18',
                            "updated": '2022-05-12T18:58:18',
                            "statu": 1,
                            "parentId": 1,
                            "name": '修改用户',
                            "path": '/sys/users',
                            "perms": 'sys:user:list',
                            "component": 'sys/User',
                            "type": 2,
                            "icon": 'el-icon-s-custom',
                            "orderNum": 1,
                            "children": []
                        },
                    ]
                },
                {
                    "id": 3,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "parentId": 1,
                    "name": '角色管理',
                    "path": '/sys/roles',
                    "perms": 'sys:role:list',
                    "component": 'sys/Role',
                    "type": 1,
                    "icon": 'el-icon-rank',
                    "orderNum": 2,
                    "children": []
                }
            ]
        },
        {
            "id": 5,
            "created": '2022-05-12T18:58:18',
            "updated": '2022-05-12T18:58:18',
            "statu": 1,
            "parentId": 1,
            "name": '系统工具',
            "path": '',
            "perms": 'sys:manage',
            "component": '',
            "type": 0,
            "icon": 'el-icon-s-operation',
            "orderNum": 1,
            "children": [
                {
                    "id": 6,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "parentId": 1,
                    "name": '数字字典',
                    "path": '',
                    "perms": 'sys:manage',
                    "component": '',
                    "type": 0,
                    "icon": 'el-icon-s-operation',
                    "orderNum": 1,
                    "children": []
                }
            ]
        }
    ]

    Result.data = menus

    return Result;
})
Mock.mock(RegExp('/sys/menu/info/*'), 'get', () => {
    Result.data = {
        "id": 3,
        "created": '2022-05-12T18:58:18',
        "updated": '2022-05-12T18:58:18',
        "statu": 1,
        "parentId": 1,
        "name": '角色管理',
        "path": '/sys/roles',
        "perms": 'sys:role:list',
        "component": 'sys/Role',
        "type": 1,
        "icon": 'el-icon-rank',
        "orderNum": 2,
        "children": []
    }

    return Result;
})
Mock.mock(RegExp('/sys/menu/*'), 'post', () => {
    return Result;
})

//角色管理
Mock.mock(RegExp('/sys/role/list*'), 'get', () => {
        Result.data = {
            "records": [
                {
                    "id": 1,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "name": '普通用户',
                    "code": 'normal',
                    "remark": '上海市普陀区金沙江路 1518 弄',
                    "menuIds": []
                }, {
                    "id": 2,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "name": '超级管理员',
                    "code": 'admin',
                    "remark": '上海市普陀区金沙江路 1518 弄',
                    "menuIds": []
                }, {
                    "id": 6,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "name": '普通用户',
                    "code": 'normal',
                    "remark": '上海市普陀区金沙江路 1518 弄',
                    "menuIds": []
                }
            ],
            "total": 3,
            "size": 10,
            "current": 1,
            "orders": [],
            "optimizeCountSql": true,
            "hitCount": false,
            "countId": null,
            "maxLimit": null,
            "searchCount": true,
            "pages": 1
        }

        return Result;
    })
Mock.mock(RegExp('/sys/role/info/*'), 'get', () => {
    Result.data =
        {
            "id": 2,
            "created": '2022-05-12T18:58:18',
            "updated": '2022-05-12T18:58:18',
            "statu": 1,
            "name": '超级管理员',
            "code": 'admin',
            "remark": '上海市普陀区金沙江路 1518 弄',
            "menuIds": []
        }

    return Result;
})
Mock.mock(RegExp('/sys/role/*'), 'post', () => {
    return Result;
})

//用户管理
Mock.mock(RegExp('/sys/user/list*'), 'get', () => {
        Result.data = {
            "records": [
                {
                    "id": 1,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "name": '普通用户',
                    "code": 'normal',
                    "remark": '上海市普陀区金沙江路 1518 弄',
                    "menuIds": []
                }, {
                    "id": 2,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "name": '超级管理员',
                    "code": 'admin',
                    "remark": '上海市普陀区金沙江路 1518 弄',
                    "menuIds": []
                }, {
                    "id": 6,
                    "created": '2022-05-12T18:58:18',
                    "updated": '2022-05-12T18:58:18',
                    "statu": 1,
                    "name": '普通用户',
                    "code": 'normal',
                    "remark": '上海市普陀区金沙江路 1518 弄',
                    "menuIds": []
                }
            ],
            "total": 3,
            "size": 10,
            "current": 1,
            "orders": [],
            "optimizeCountSql": true,
            "hitCount": false,
            "countId": null,
            "maxLimit": null,
            "searchCount": true,
            "pages": 1
        }

        return Result;
    })
Mock.mock(RegExp('/sys/user/info/*'), 'get', () => {
    Result.data =
        {
            "id": 2,
            "created": '2022-05-12T18:58:18',
            "updated": '2022-05-12T18:58:18',
            "statu": 1,
            "name": '超级管理员',
            "code": 'admin',
            "remark": '上海市普陀区金沙江路 1518 弄',
            "menuIds": []
        }

    return Result;
})
Mock.mock(RegExp('/sys/user/*'), 'post', () => {
    return Result;
})
